package com.cs2.volunteerpostbackend.web.dto;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

public class RespEntity {
    private String code;
    private String msg;
    private Object data;

    public RespEntity(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> RespEntity success(T data) {
        return new RespEntity("200", "success", data);
    }

    public static <T> RespEntity success(String msg) {
        return new RespEntity("200", msg, null);
    }

    public static <T> RespEntity error(String msg) {
        return new RespEntity("500", msg, null
        );
    }

    public static <T> RespEntity error(T data) {
        return new RespEntity("500", "error", data);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
